/**
 * Created by duanq on 2017/4/5.
 */
import React ,{Component} from 'react';
import axios from 'axios';
import { Table } from 'antd';
import 'antd/dist/antd.css';

const columns = [{
    title: '姓名',
    dataIndex: 'userName',
    key: 'userName',
}, {
    title: 'Email',
    dataIndex: 'email',
    key: 'email',
}, {
    title: '角色',
    dataIndex: 'role',
    key: 'role',
}, {
    title: '创建时间',
    dataIndex: 'create_time',
    key: 'create_time',
}, {
    title: '更新时间',
    dataIndex: 'update_time',
    key: 'update_time',
}];
// rowSelection object indicates the need for row selection
const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
        console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
    },
    onSelect: (record, selected, selectedRows) => {
        console.log(record, selected, selectedRows);
    },
    onSelectAll: (selected, selectedRows, changeRows) => {
        console.log(selected, selectedRows, changeRows);
    },
    getCheckboxProps: record => ({
        disabled: record.name === 'Disabled User',    // Column configuration not to be checked
    }),
};
export default class Home extends Component{
    constructor(props){
        super(props);
        this.state = {userData:[{null}]};
        let that = this;
        axios.get('home')
            .then(function (response) {
                that.setState({userData:response.data});
            })
            .catch(function (error) {
                console.log(error);
            });
    }
    render(){
        return (
            <div>
                <Table dataSource={this.state.userData} columns={columns} />
            </div>
        );
    }
}
